<template>
	<page-meta :root-font-size="getRootFontSize()"></page-meta>
	<uni-popup ref="signOutShow" type="center" :animation="false">
		<view class="loginBox">
			<view class="imgBox"><image style="width: 100%; height: 100%;" mode="scaleToFill" src="/static/icon/superAnt/Warning-2801.png"></image></view>
			<view class="titleBox">{{ i18n.ctwfont12 }}？</view>
			<view class="btnBox">
				<button size="mini" @tap="close" class="upImgBottomBoxL" type="default">{{ i18n.ctwfont13 }}</button>
				<button size="mini" @tap="goLogin" class="upImgBottomBoxR" type="default">{{ i18n.ctwfont6 }}</button>
			</view>
		</view>
	</uni-popup>
</template>

<script>
import { clearStorage, removeAllCookie, setStorage, removeCookie, getStorage } from '@/utils/setStorage.js';
import { baseUrl } from '@/utils/http.js';
import baseFont from '@/utils/baseFont.js';
export default {
	extends: baseFont,
	data: function() {
		return {};
	},
	computed: {
		i18n() {
			return this.$t('login');
		}
	},
	methods: {
		// 开启
		open() {
			this.$refs.signOutShow.open();
		},
		// 关闭
		close() {
			this.$refs.signOutShow.close();
		},
		async goLogin(e) {
			const lang = getStorage('language') || 'th';
			const popUpOne = getStorage('popUpOnePermanentShow');
			const popUpTwo = getStorage('popUpTwoPermanentShow');
			const popUpThree = getStorage('popUpThreePermanentShow');
			clearStorage();
			removeAllCookie();
			removeCookie(baseUrl);
			// 多语言重新赋值
			setTimeout(() => {
				setStorage('language', lang);
				// 推出时保证广告一不被清除
				setStorage('popUpOnePermanentShow', popUpOne);
				// 推出时保证广告二不被清除
				setStorage('popUpTwoPermanentShow', popUpTwo);
				// 推出时保证广告三不被清除
				setStorage('popUpThreePermanentShow', popUpThree);
				this.$refs.signOutShow.close();
				this.$emit('closeSignOut', true);
				// #ifdef APP-PLUS
				uni.reLaunch({
					url: '/pages/home/index'
				});
				// #endif
				// #ifdef H5
				this.$Router.push('/pages/home/index');
				// #endif
			}, 300);

			// const params = {
			// 	geTuiCid: this.getCID()
			// };
			// const { data: res } = await this.$http(true, 'ptpz/yonghu/loginOut', params, 'POST');
			// if (res.code !== '0000') {
			// 	return this.$message({
			// 		type: 'error',
			// 		message: '退出失败',
			// 		center: true
			// 	});
			// } else {
			// 	clearStorage();
			// 	removeAllCookie();
			// 	removeCookie(baseUrl);
			// 	// this.$Router.push('/pages/logins/loging');
			// 	uni.reLaunch({
			// 		url: '/pages/logins/loging'
			// 	});
			// }
		}
	}
};
</script>

<style lang="scss" scoped>
.loginBox {
	position: fixed;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	.imgBox {
		width: 100px;
		height: 100px;
		border-radius: 10px;
		margin: auto;
		overflow: hidden;
	}
	.titleBox {
		margin-top: 10px;
		font-size: 18px;
		text-align: center;
		color: #ebedf3;
	}
	.btnBox {
		width: 600rpx;
		display: flex;
		justify-content: space-around;
		margin-top: 15px;
		.upImgBottomBoxL {
			background-color: #fff;
			padding: 0 25px;
			border-radius: 15px;
			color: #cd001b;
			line-height: 2;
			margin: 0;
			font-size: 16px;
		}
		.upImgBottomBoxR {
			background-color: #d80c24;
			padding: 0 25px;
			border-radius: 15px;
			color: #ffffff;
			line-height: 2;
			margin: 0;
			font-size: 16px;
		}
	}
}
</style>
